package bairui.international.console.web.controller.finance.withdraw;

/**
 *
 * ExcelOutput_ExcelExport_Output_Admin_Detail
 * excel输出
 */
class ExcelOutput_ExcelExport_Output_Admin_Detail

{

	/**
	 * 创建sheet
	 */
	public static com.sh_lianjing.file.excel.write.ExcelWriter createSheet(
		String sheetName,
		java.util.List<Model> list
	) throws Exception{
		return createSheet(sheetName, com.sh_lianjing.file.excel.write.ExcelWriter.newInstanceExcel2007BigData(), list);
	}
	
	public static com.sh_lianjing.file.excel.write.ExcelWriter createSheet(
		String sheetName,
		com.sh_lianjing.file.excel.write.ExcelWriter writer,
		java.util.List<Model> list
	) throws Exception{
		return createSheet(sheetName, writer, Model.class, list, null);
	}

	public static <E extends Model, D> com.sh_lianjing.file.excel.write.ExcelWriter createSheet(
		String sheetName,
		com.sh_lianjing.file.excel.write.ExcelWriter writer,
		Class<E> type,
		java.util.List<E> list,
		D headCommentsData
	) throws Exception{
		return writer
				.createSheet(
					sheetName, 
					type,
					list,
					headCommentsData
				);
	}

	/**
	 * 输出文件
	 */
	public static void output(
		java.util.List<Model> list,
		javax.servlet.http.HttpServletRequest request,
		javax.servlet.http.HttpServletResponse response
	) throws Exception{
		output(
			"分公司提现单", 
			createSheet("分公司提现单", list), 
			request, 
			response
		);
	}

	public static void output(
		String fileName,
		com.sh_lianjing.file.excel.write.ExcelWriter writer,
		javax.servlet.http.HttpServletRequest request,
		javax.servlet.http.HttpServletResponse response
	) throws Exception{
		// 设置格式
		com.lianjing.sh.web.common.util.Util_Web.setDownloadFileName(request, response, fileName+".xlsx");
		response.setContentType(org.springframework.http.MediaType.APPLICATION_XML_VALUE);
		// 生成excel并输出
		try{
			writer.writeTo(response.getOutputStream());
		} finally {
			writer.close();
		};
	}

	
	/**
	 * 排序扩展接口
	 */
	static interface OrderExtends {
		org.springframework.data.domain.Sort gainNickName(
			org.springframework.data.domain.Sort.Direction direction
		);
		org.springframework.data.domain.Sort gainRealName(
			org.springframework.data.domain.Sort.Direction direction
		);
		org.springframework.data.domain.Sort gainPhone(
			org.springframework.data.domain.Sort.Direction direction
		);
		
	
		default org.springframework.data.domain.Sort sort(
			org.springframework.data.domain.Sort.Direction direction,
			com.querydsl.core.types.dsl.ComparableExpressionBase<?> ... sortBase
		){
			return com.lianjing.sh.spring.web.controller.enhance.output.order.util.Util_Order.sortTrans(direction, sortBase);
		}
	
		default com.querydsl.core.types.OrderSpecifier<?> order(
			org.springframework.data.domain.Sort.Direction direction,
			com.querydsl.core.types.dsl.ComparableExpressionBase<?> orderBase
		){
			return com.lianjing.sh.spring.web.controller.enhance.output.order.util.Util_Order.orderTrans(direction, orderBase);
		}
	}
	
	/**
	 * 排序
	 */
	final static org.springframework.data.domain.Sort sort(
		bairui.international.model.domain.jpa.QTB_BranchCompanyWithdrawOrder QRoot,
		javax.servlet.http.HttpServletRequest request
		,OrderExtends orderExtends
	){
		/*
		 * 排序属性
		 */
		// orderBy @RequestParam(name="orderBy", required=false, defaultValue="orderValue") String orderBy
		String orderByPara = request.getParameter(com.lianjing.sh.web.separatepage.OrderInfo.OrderBy);
		if(null == orderByPara){
			orderByPara = "submitDate";
		}
		// orderWay @RequestParam(name="orderWay", required=false, defaultValue="DESC") OrderWay orderWay
		String orderWayPara = request.getParameter(com.lianjing.sh.web.separatepage.OrderInfo.OrderWay);
		if(null == orderWayPara){
			orderWayPara = "DESC";
		}
		org.springframework.data.domain.Sort.Direction direction = org.springframework.data.domain.Sort.Direction.valueOf(orderWayPara);
	
		//
		switch(orderByPara){
			case "number":		return com.lianjing.sh.spring.web.controller.enhance.output.order.util.Util_Order.sortTrans(direction, QRoot.number);
			case "submitDate":		return com.lianjing.sh.spring.web.controller.enhance.output.order.util.Util_Order.sortTrans(direction, QRoot.submitDate);
			case "money":		return com.lianjing.sh.spring.web.controller.enhance.output.order.util.Util_Order.sortTrans(direction, QRoot.money);
			case "nickName":		return orderExtends.gainNickName(direction);
			case "realName":		return orderExtends.gainRealName(direction);
			case "phone":		return orderExtends.gainPhone(direction);
			case "accountNumber":		return com.lianjing.sh.spring.web.controller.enhance.output.order.util.Util_Order.sortTrans(direction, QRoot.accountNumber);
			case "bank":		return com.lianjing.sh.spring.web.controller.enhance.output.order.util.Util_Order.sortTrans(direction, QRoot.bank);
			case "state":		return com.lianjing.sh.spring.web.controller.enhance.output.order.util.Util_Order.sortTrans(direction, QRoot.state);
			default:
				throw new RuntimeException();
		}
	}
	

	@com.sh_lianjing.file.excel.write.annotation.WriteExcel
	@SuppressWarnings(value="serial")
	abstract 
	public static class Model extends bairui.international.model.domain.jpa.TB_BranchCompanyWithdrawOrder{
	
		/**
		 * 构造函数
		 */
		@lombok.Getter @com.fasterxml.jackson.annotation.JsonIgnore
		private bairui.international.model.domain.jpa.TB_BranchCompanyWithdrawOrder _origin;
	
		public Model(
			bairui.international.model.domain.jpa.TB_BranchCompanyWithdrawOrder bean
		) {
			this._origin = bean;
			if(null != bean){
				this.setId(bean.getId());
				this.setNumber(bean.getNumber());
				this.setSubmitDate(bean.getSubmitDate());
				this.setMoney(bean.getMoney());
				this.setAccountNumber(bean.getAccountNumber());
				this.setBank(bean.getBank());
				this.setState(bean.getState());
			}
			/* 附加属性赋值前 */
			assign_before();
			/* 附加属性赋值 */
			this.setNickName(this.assignNickName());
			this.setRealName(this.assignRealName());
			this.setPhone(this.assignPhone());
		}
		
		
		@com.sh_lianjing.reflect.method.annotation.MethodOrder(2)
		@com.sh_lianjing.file.excel.write.annotation.WriteExcelCell(comment = "编号")
		
		@Override
		public String getNumber() {
			return (String)super.getNumber();
		}
		
		@com.sh_lianjing.reflect.method.annotation.MethodOrder(3)
		@com.sh_lianjing.file.excel.write.annotation.WriteExcelDateFormat(pattern = "yyyy-MM-dd")
		@com.sh_lianjing.file.excel.write.annotation.WriteExcelCell(comment = "提交时间")
		
		@Override
		public java.util.Date getSubmitDate() {
			return (java.util.Date)super.getSubmitDate();
		}
		
		@com.sh_lianjing.reflect.method.annotation.MethodOrder(4)
		@com.sh_lianjing.file.excel.write.annotation.WriteExcelCell(comment = "金额")
		
		@Override
		public Double getMoney() {
			return (Double)super.getMoney();
		}
		
		@com.sh_lianjing.reflect.method.annotation.MethodOrder(5)
		@com.sh_lianjing.file.excel.write.annotation.WriteExcelCell(comment = "昵称")
		/** get[昵称] */
		public String getNickName() {
			return this.nickName;
		}
		
		@com.sh_lianjing.reflect.method.annotation.MethodOrder(6)
		@com.sh_lianjing.file.excel.write.annotation.WriteExcelCell(comment = "用户姓名")
		/** get[用户姓名] */
		public String getRealName() {
			return this.realName;
		}
		
		@com.sh_lianjing.reflect.method.annotation.MethodOrder(7)
		@com.sh_lianjing.file.excel.write.annotation.WriteExcelCell(comment = "用户电话")
		/** get[用户电话] */
		public String getPhone() {
			return this.phone;
		}
		
		@com.sh_lianjing.reflect.method.annotation.MethodOrder(8)
		@com.sh_lianjing.file.excel.write.annotation.WriteExcelCell(comment = "提现账号")
		
		@Override
		public String getAccountNumber() {
			return (String)super.getAccountNumber();
		}
		
		@com.sh_lianjing.reflect.method.annotation.MethodOrder(9)
		@com.sh_lianjing.file.excel.write.annotation.WriteExcelCell(comment = "开户行")
		
		@Override
		public String getBank() {
			return (String)super.getBank();
		}
		
		@com.sh_lianjing.reflect.method.annotation.MethodOrder(10)
		@com.sh_lianjing.file.excel.write.annotation.WriteExcelCell(comment = "状态")
		
		@Override
		public bairui.international.model.status.State_BranchCompanyWithdrawOrder getState() {
			return (bairui.international.model.status.State_BranchCompanyWithdrawOrder)super.getState();
		}
		
		
		/**
		 * 非继承属性
		 */
		abstract protected void assign_before();
		
		/** 昵称 */
		 @lombok.Setter 
		private String nickName;
		/** 赋值昵称 */
		abstract protected String assignNickName();
	
		/** 用户姓名 */
		 @lombok.Setter 
		private String realName;
		/** 赋值用户姓名 */
		abstract protected String assignRealName();
	
		/** 用户电话 */
		 @lombok.Setter 
		private String phone;
		/** 赋值用户电话 */
		abstract protected String assignPhone();
	
		/**
		 * 相关类
		 */
	}
	

}

